import Vue from 'vue'
import VueRouter from 'vue-router'

import Index from "@views/index/index.vue";
import Dashboard from "@views/dashboard/index.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    component: Index,
    meta: {
      title: "首页"
    }
  },
  {
    path: '/index/:id',
    component: Index,
    meta: {
      title: "首页"
    }
  },
  {
    path: '/dashboard',
    component: Dashboard,
    meta: {
      title: "控制台"
    }
  },
  {
    path: '*',
    redirect: '/'
  },
];


const router = new VueRouter({
  routes,
  mode: 'hash'
});

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next();
});

export default router

